home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir24 / nosinst.zip / TUTORETC.ZIP / ROUTING.TXT < prev   
Text File  |  1993-12-13  |  7KB  |  163 lines

  1. How IP bit masking works - G4POI July 13th 1993
  2.  
  3. ========================================================================
  4.           HOW ROUTING USING IP ADDRESS BIT MASKING WORKS
  5. ========================================================================
  6.  
  7. Ever wondered how mail gets passed around the tcp/ip network and ends
  8. up in the right region at the right hub? (When it works that is!).
  9.  
  10.  
  11. WHAT AN IP ADDRESS REALLY IS:
  12. =============================
  13. A IP address is a four byte number. A byte is a number that can be anything
  14. between 0, and 255 in value. How does that work? Well a byte is made up
  15. of 8 binary bits, and a binary bit is a single digit that can only be
  16. a 0 or 1. Confusing isn't it?... Look at this;
  17.  
  18.  
  19.                               ONE BYTE
  20.                               ========
  21.  
  22.                   128  64  32  16  8   4   2   1   <-- what each "bit"
  23.                                                        represents
  24.  
  25.                    0   0   0   0   0   0   0   0   <-- binary "bits"
  26.  
  27.  
  28. Just follow this through and see how much sense it makes.
  29.  
  30. When all of the binary "bits" are 0, then the total value of the byte is 0.
  31. Now lets change the value of some of the "bits" in our "byte".
  32.  
  33.                                         ______________________
  34.                                        /                      \
  35.                    0   0   0   0   0   1   0   1              |
  36.                                               /               |
  37. We have changed the right most "bit" to a 1 -'  and also the 3rd from the
  38. right also to a 1. Look at the top diagram (ONE BYTE). The right most
  39. "bit" corresponds to the value 1, and the third from right hand "bit"
  40. corresponds to a value of 4. So the total value of our new byte, is
  41. 1 + 4 which equals 5 (good job I've got a calculator!).
  42.  
  43.  
  44. If we change the "bits" to this combination;
  45.  
  46.                    0   0   1   0   1   1   0   0
  47.  
  48. thats;             0 + 0 + 32+ 0 + 8 + 4 + 0 + 0   = 44   Familiar?
  49.  
  50.  
  51. This is what an IP address of 44.131.19.160 looks like in binary;
  52.                              /   /     \   \                
  53.                      _______/   /       \   \__________   
  54.                     /          /         \             \  
  55.                 00101100    10000011    00010011    10100000
  56.  
  57.  
  58. BIT MASKING:
  59. ============
  60. Now suppose we took that address (44.131.19.160) and only looked
  61. at the first 28 bits. Let's redraw the example and make it a bit more
  62. compressed so we can fit more information in.
  63.  
  64.  
  65.                    44   .  131   .   19   .  160
  66.                 00101100.10000011.00010011.10100000
  67.                 `-----------------------------'
  68.                        The first 28 bits
  69.  
  70. And lets say that whatever happens, that these first 28 bits MUST be an
  71. exact match but the remaining 4 bits on the right can add up to any value
  72. and we aren't bothered about them. Lets see what that actually means.
  73.  
  74. Just looking at the right most BYTE of the address, the 160 part of the
  75. address, if the left four bits always have to be 1010 (they do because
  76. they are included in the 28 bits which must be an exact match), then
  77. changing just the right hand four bits produces these numbers;
  78.  
  79.                         10100000       160
  80.                         10100001       161
  81.                         10100010       162
  82.                         10100011       163
  83.                         10100100       164
  84.                            .            .   and so on up
  85.                            .            .   until
  86.                         10101111       175
  87.  
  88. 175 is the highest number we can go up to without altering any of the
  89. four left hand bits. So if for instance G4HPE hub says in one of his
  90. configuration files (R_AIR.LST);
  91.  
  92.                route add 44.131.19.160/28 uhf g4poi
  93.  
  94. It means that anything with an address of 44.131.19.160 to 44.131.19.175
  95. should be sent to station g4poi via his uhf interface. You can now
  96. see what the /28 means on the above address. i.e. the first 28 bits must
  97. match exactly but I don't care about the rest.
  98.  
  99. If I said that the g4poi hub address is 160 and the next hub up is 176,
  100. then this will now make sense to you.... yes?!! Quite right! It's all
  101. to do with bit masking! And so will any changeover of addresses.
  102.  
  103. Further reading: I recommend you read IP_PROP.TXT in /public/tcpip/news.
  104. It should now make far more sense as to why the addresses proposed
  105. are the values that they are.
  106.  
  107.  
  108. TOMORROW THE WORLD!:
  109. ====================
  110. I'm going to expand this explanation to show how (in theory at least),
  111. some mail could come all the way from the USA Internet network (thats the
  112. wire version of what we use) to sunny Northaw village ("on sea" if the polar
  113. caps melt and the tides in!). Please bare in mind that Internet uses
  114. domain names (that's the .ampr.org. type part of it) for much of the
  115. routing but this is after all just an imaginary example to make things
  116. clearer.
  117.  
  118.  
  119. Fred writes a message to say; "Hiya Dave. I've booked you a seat on
  120. concorde so you can pop in for lunch". (I wish!). And his system looks
  121. up g4poi.ampr.org and comes back with the ip address 44.131.19.160.
  122.  
  123. His Internet "HUB" (equivalent of) has an entry in its routing table
  124. that looks like this;
  125.  
  126.              route add 44.0.0.0/8 modem k1ham 
  127.  
  128. Which routes any address with the first 8 bits matching the value of
  129. 44 exactly (amateur radio packet), down the modem line to a local ham
  130. station called k1ham.
  131.  
  132. k1ham has the following entry in his routing table;
  133.  
  134.              route add 44.131.0.0/16 uksat g9ham
  135.  
  136. Which routes any traffic for the United Kingdom (131) up on to satellite
  137. link to station g9ham who lives in England in the Stevenage area.
  138.  
  139. g9ham has the following in his routing table;
  140.  
  141.             route add 44.131.19.0/24 uhf g4hpe
  142.  
  143. Which routes all region 19 traffic to g4hpe.
  144.  
  145. g4hpe (Steve), a real ham if ever there was one (hi!) has the following
  146. entry in his routing table;
  147.  
  148.             route add 44.131.19.160/28 uhf g4poi
  149.  
  150. Which routes anything that has an address within the range of
  151. 44.131.19.160 to 44.131.19.175 to me (g4poi).
  152.  
  153. I see the message arrive and read it. My reply would find its way back
  154. to fred in the states by a very similar process (carrier pigeon).
  155.  
  156. So at each stage, "bit masking", i.e. only taking notice of certain "bits"
  157. of the address, is used to route the mail in ROUGHLY the right direction
  158. right down to the final stage where it arrives at its actual destination.
  159.  
  160. And that, my friends, is how we do it at the moment!
  161.  
  162. 73 de Dave g4poi@g4poi.ampr.org
  163.